home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1990: Discy Business / Discy Business.2mg / DEV.CD / TOOLS / TECH.NOTES / IIGS / TN.IIGS.035 < prev    next >
Encoding:
Text File  |  1990-03-03  |  35.0 KB  |  920 lines  |  [04] ASCII Text (0x0000)

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5. Apple IIGS
  6. #35:    Printer Driver Specifications
  7.  
  8. Revised by:    Matt Deatherage & Ben Koning    March 1990
  9. Written by:    Dan Hitchens, Matt Deatherage & Suki Lee    May 1988
  10.  
  11. This Technical Note describes the routines and internal structures needed to 
  12. design a printer driver for the Apple IIGS system, and you should reference it 
  13. in conjunction with the Apple IIGS Toolbox Reference manuals.  An overview and 
  14. associated parameters for each of the printer driver routines are in the Print 
  15. Manager chapter, and you should reference these for a complete picture.
  16. Changed since September 1989:  Corrected the description of 
  17. PrGetPageOrientation.
  18. _____________________________________________________________________________
  19.  
  20. Printing Modes
  21.  
  22. There are two printing modes:  immediate and deferred.
  23.  
  24. o  Immediate mode (also known as draft mode), uses the technique of 
  25.    printing immediately.  As you make QuickDraw II calls, you 
  26.    immediately generate commands which cause printing to occur.  This 
  27.    mode is the fastest form of printing, but it can only print 
  28.    characters in the printer's native mode.  (However, the 
  29.    LaserWriter translates the QuickDraw II calls into PostScript 
  30.    calls which can produce high-quality pixelmap images.)
  31.  
  32. o  Deferred mode (sometimes referred to as spooling), uses the 
  33.    technique of capturing the QuickDraw II calls for each page in a 
  34.    picture file and plays them back at a later time.  To produce 
  35.    high-quality pixelmap images, you must use deferred mode because 
  36.    of the memory constraint of not being able to draw a complete page 
  37.    in memory at one time.  Due to this limitation, you draw a band (a 
  38.    partial page) at a time.  You create a GrafPort which corresponds 
  39.    to the band and play the picture file back, thus causing the saved 
  40.    commands to draw only the images which fall within the band.  Once 
  41.    the pixel image for the band is generated, you can send it to the 
  42.    printer one pixel at a time.
  43.  
  44.  
  45. File Structure
  46.  
  47. The user can install new printer drivers into the system by copying a printer 
  48. driver file into a subdirectory called DRIVERS within the SYSTEM subdirectory.  
  49. The printer driver file must be of type $BB and have an auxiliary type of 
  50. $0001.
  51.  
  52.  
  53. Print Driver Calls
  54.  
  55. A printer driver must support the following calls:
  56.  
  57.     PrDefault               $0913    Sets print record to default
  58.     PrValidate              $0A13    Validates print record
  59.     PrStlDialog             $0B13    Performs a style dialog
  60.     PrJobDialog             $0C13    Performs a job dialog
  61.     PrPixelMap              $0D13    Prints a pixelmap
  62.     PrOpenDoc               $0E13    Opens the document
  63.     PrCloseDoc              $0F13    Closes the document
  64.     PrOpenPage              $1013    Opens a page
  65.     PrClosePage             $1113    Closes a page
  66.     PrPicFile               $1213    Prints a picture file
  67.     --RESERVED--            $1313
  68.     PrError                 $1413    Gets the error value
  69.     PrSetError              $1513    Sets the error value
  70.     GetDeviceName           $1713    Gets device's name
  71.     PrDriverVer             $2313    Gets installed driver version
  72.  
  73. Printer drivers may support the following calls if they use the new driver 
  74. structure outlined below:
  75.  
  76.     PrGetPrinterSpecs       $1813    Returns printer type and 
  77.                                      characteristics
  78.     PrGetPageOrientation    $3813    Returns page orientation
  79.  
  80.  
  81. Print Driver Entry
  82.  
  83. o  For older drivers, entry is at the first byte (no offset).  For newer 
  84.    (Print Manager 3.0 and later) drivers, the first word is $0000, indicating 
  85.    a new style driver. The next word is a count of how many calls this driver 
  86.    supports. All drivers must support the minimum call set.  Additional calls 
  87.    must be supported in the sequence listed (for example, if a driver supports 
  88.    PrGetPageOrientation, it must also support PrGetPrinterSpecs).
  89. o  The content of the x register is calculated beforehand for use as an index 
  90.    to the correct routine (see the example and note the specific ordering of 
  91.    the routines).
  92. o  There are two long return addresses (six bytes) that have been pushed onto 
  93.    the stack.  (You must take these addresses into account to access the 
  94.    parameters and to return correctly.)
  95.  
  96. Example
  97.  
  98. StartOfDriver START
  99.  
  100.               dc  i2'0'            ; new style driver
  101.               dc  i2'16'
  102.  
  103.               jmp (PrDriverList,x)
  104.  
  105. PrDriverList  dc  a4'PrDefault'
  106.               dc  a4'PrValidate'
  107.               dc  a4'PrStlDialog'
  108.               dc  a4'PrJobDialog'
  109.               dc  a4'PrPixelMap'
  110.               dc  a4'PrOpenDoc'
  111.               dc  a4'PrCloseDoc'
  112.               dc  a4'PrOpenPage'
  113.               dc  a4'PrClosePage'
  114.               dc  a4'PrPicFile'
  115.               dc  a4'InvalidRoutine'
  116.               dc  a4'PrError'
  117.               dc  a4'PrSetError'
  118.               dc  a4'GetDeviceName'
  119.               dc  a4'PrDriverVer'
  120.               dc  a4'PrGetPrinterSpecs'
  121.               dc  a4'PrGetPageOrientation'
  122.  
  123.  
  124. Print Driver Exit
  125.  
  126. You should adjust the stack to use RTL instructions followed by any return 
  127. parameters with the two long return addresses.  To accomplish this, you need 
  128. to do the following:
  129.  
  130. o  Eliminate any parameters from the stack which have been passed.
  131. o  Move the long return addresses so that they are before the space 
  132.    for the returned parameters (if any).
  133.  
  134. Example
  135.  
  136. Figure 1 diagrams the stack just before leaving the print driver:
  137.  
  138.              | Previous Contents
  139.              +---------------------
  140.              | Results (if any)
  141.              +---------------------
  142.              | RTL2 (3 bytes)
  143.              +---------------------
  144.              | RTL1 (3 bytes)
  145.              +---------------------
  146.                                    <--- Stack Pointer
  147.  
  148.  
  149.            Figure 1-Stack Prior to Exiting the Print Driver
  150.  
  151. You should do an RTL with the contents of the flags and registers set 
  152. appropriately.  (See the Return from Call section of the "Using The Apple 
  153. Tools" chapter of the Apple IIGS Toolbox Reference.)
  154.  
  155.  
  156. Print Record Structure
  157.  
  158. Since application programs often need to fiddle with parts of the print record 
  159. (i.e., the values in the style subrecord), we have defined ways for 
  160. applications to interpret the print record, and specifically the style 
  161. subrecord.
  162.  
  163. iDev, the first word of the printer information subrecord, has two defined 
  164. values for third-party printer drivers.  A value of $8001 indicates a dot-
  165. matrix printer while a value of $8003 indicates a laser printer.
  166.  
  167. A value of $8001 indicates that fields of the style subrecord should be 
  168. interpreted as they are by the ImageWriter driver, as documented in the Apple 
  169. IIGS Toolbox Reference.  The first seven bits (0-6) of wDev are defined as for 
  170. the ImageWriter driver.  Bits 7-11 are reserved for Apple's use and must be 
  171. set to zero.  Bits 12-15 may be used by third-party printer drivers as 
  172. necessary; these bits are set to zero in Apple's drivers.
  173.  
  174. A value of $8003 indicates that fields of the style subrecord should be 
  175. interpreted as they are by the LaserWriter driver.  The first four bits (0-3) 
  176. of wDev are defined as for the LaserWriter driver.  Bits 4-11 are reserved for 
  177. Apple's use and must be set to zero.  Bits 12-15 may be used by third-party 
  178. printer drivers as necessary; these bits are set to zero in Apple's drivers.
  179.  
  180. If an application wishes to take advantages of specific features of a third-
  181. party printer driver, it has to know that it is dealing with that driver.  
  182. Since all drivers look pretty much alike, the Print Manager allows you to ask 
  183. for the name of the currently selected printer driver.  An application may 
  184. make the Print Manager call PMGetPrinterName, which is documented in this 
  185. Note.  The Print Manager returns the name of the currently selected printer in 
  186. a Pascal (length byte) string.  The name returned is the name of the file from 
  187. which the driver was loaded.  If you intend to use this method to identify a 
  188. driver, you must inform users not to rename the Printer Driver file on the 
  189. boot disk.
  190.  
  191.  
  192. The PMGetPrinterName call is as follows:
  193.  
  194. Note:  This is a Print Manager call, not a Printer Driver call.  It is 
  195.        the only Print Manager call documented in this Note.  Printer 
  196.        Drivers do not include this call.
  197.  
  198. PMGetPrinterName         ($2813)
  199.  
  200. Description:
  201.     Returns a Pascal string with the file name of the currently selected 
  202.     printer driver.
  203.  
  204. Passed:
  205.     Longspace            LONG        Space for result
  206.  
  207. Returned:
  208.     NamePointer          LONG        Pointer to a Pascal string of driver 
  209.                                      filename
  210.  
  211.  
  212. Print Driver Calls
  213.  
  214. PrDefault                ($0913)
  215.  
  216. Description:
  217.     Fills the fields of the specified print record with default values for the 
  218.     printer.
  219.  
  220. Passed:
  221.     PrintRecordHandle    LONG        Handle to the print record
  222.  
  223. Returned:
  224.     None
  225.  
  226. Performs the following:
  227. o  Validates that PrintRecordHandle is a handle and does nothing if not.
  228. o  Determines the default values for the print record either through tables or 
  229.    calculations.  The default values should take into account such things as 
  230.    paper size and orientation, print mode, printer type, etc.
  231. o  Copies the default values to the print record specified by the 
  232.    PrintRecordHandle parameter.
  233.  
  234.  
  235. PrValidate               ($0A13)
  236.  
  237. Description:
  238.     Checks the print record to see that it is valid for the currently installed 
  239.     printer driver.
  240.  
  241. Passed:
  242.     PrintRecordHandle    LONG        Handle to the print record
  243.  
  244. Returned:
  245.     ChangeFlag           WORD        Boolean; TRUE if the record is adjusted
  246.  
  247. Performs the following:
  248. o  Checks to see if the print record is from this particular driver.
  249. o  If the print record is not from this driver, it uses the default values for 
  250.    this driver.
  251. o  If the print record is from this driver, it makes any changes that might be 
  252.    needed (i.e., style, paper size, etc.).
  253.  
  254.  
  255. PrStlDialog              ($0B13)
  256.  
  257. Description:
  258.     Performs a style dialog with the user.
  259.  
  260. Passed:
  261.     PrintRecordHandle    LONG        Handle to the print record
  262.  
  263. Returned:
  264.     ConfirmFlag          WORD        Boolean; TRUE if the dialog is confirmed
  265.  
  266. Performs the following:
  267. o  Conducts a style dialog with the user to determine the page dimensions and 
  268.    other information needed for page setup (the initial settings of the dialog 
  269.    are derived from the print record).
  270. o  If the user confirms the dialog, the information from the dialog is saved 
  271.    in the specified print record, PrValidate is called, and the routine 
  272.    returns TRUE.
  273. o  If the user cancels the dialog, the print record is left unchanged, and the 
  274.    routine returns FALSE.
  275.  
  276. Note:  The following are items typically found in printer style dialogs:
  277.  
  278. o  Paper Size (US Letter, US Legal, A4 Letter, B5 Letter, International 
  279.    Fanfold)
  280. o  Printing Orientation (Landscape, Portrait)
  281. o  Vertical Sizing (Normal, Intermediate, Condensed)
  282. o  Special Effects:
  283.      Font Effects (Font Substitution, Smoothing)
  284.      Reduction or Enlargement
  285.      Gaps or No Gaps between pages
  286.  
  287. Every printer style dialog should have an OK button (default) and a Cancel 
  288. button.
  289.  
  290.  
  291. PrJobDialog              ($0C13)
  292.  
  293. Description:
  294.     Performs a job dialog with the user.
  295.  
  296. Passed:
  297.     PrintRecordHandle    LONG        Handle to the print record
  298.  
  299. Returned:
  300.     ConfirmFlag          WORD        Boolean; True if the dialog is confirmed
  301.  
  302. Performs the following:
  303. o  Conducts a job dialog with the user to determine the print quality, range 
  304.    of pages to print, and other specifications.  The initial settings are 
  305.    derived from the previous PrJobDialog call (or initial default values) 
  306.    except the page range which is set to ALL, and the number of copies which 
  307.    is set to ONE.
  308. o  If the user confirms the dialog, PrValidate is called, the print record is 
  309.    updated, and the routine returns TRUE.
  310. o  If the user cancels the dialog, the print record is left unchanged, and the 
  311.    routine returns FALSE.
  312.  
  313. Note:  The following are items typically found in printer job dialogs:
  314.  
  315.        o  Print Quality (Best, Faster, Draft, etc.)
  316.        o  Color option
  317.        o  Pages (All, Range)
  318.        o  Copies
  319.        o  Paper Source (paper cassette, manual feed)
  320.  
  321. Every printer job dialog should have an OK button (default) and a Cancel 
  322. button.
  323.  
  324.  
  325. PrPixelMap               ($0D13)
  326.  
  327. Description:
  328.     Prints all or part of the specified pixelmap.
  329.  
  330. Passed:
  331.     srcLocPtr            LONG        Pointer to the source LocInfo which 
  332.                                      contains the pointer to the pixelmap.
  333.     srcRectPtr           LONG        Pointer to the rectangle which encloses 
  334.                                      the pixelmap to be printed.
  335.     colorFlag            WORD        Boolean; FALSE if black and white,
  336.                                      TRUE if color.
  337.  
  338. Returned:
  339.     None
  340.  
  341. Performs the following:
  342. o  Calls DevIsItSafe (port driver call) to verify that the port it functioning 
  343.    and it is safe to proceed.  If it is not functioning, set the internal 
  344.    error code to $1302 (Port Not On) and return with an error status.
  345. o  Saves the current port.
  346. o  Turns on the watch cursor to signal the user that it will take some time.
  347. o  Clears the internal error code (default, if no errors occur).
  348. o  Gets a new handle for a print record and set it to the defaults by calling 
  349.    PrDefault.
  350. o  If colorFlag is set, sets bit 5 of wdev in prStl of the print record.
  351. o  Do any initialization that might be needed by the driver.
  352. o  Determine the intersection of the two rectangles (rectangle pointed to by 
  353.    srcRectPtr and the pixelmap's boundary rectangle from srcLocPtr) and if 
  354.    there is no intersection, then nothing is to be printed.
  355. o  Print the pixel image which is within the intersection of the two 
  356.    rectangles.
  357. o  Cause a page eject to occur on the printer.
  358. o  Do any clean up that is needed.
  359. o  Turn off the watch cursor by calling InitCursor.
  360. o  Restore the port by calling SetPort.
  361.  
  362.  
  363. PrOpenDoc                ($0E13)
  364.  
  365. Description:
  366.     This routine initializes the things needed to open a document.  In deferred 
  367.     mode, it establishes a GrafPort and makes it the current port for printing.
  368.  
  369. Passed:
  370.     PrintRecordHandle    LONG        Handle to the print record
  371.     PrinterPortPtr       LONG        Pointer to the GrafPort, if desired, zero 
  372.                                      to allocate a new GrafPort
  373. Returned:
  374.     PrinterPortPtrRet    LONG        Pointer to the GrafPort if the 
  375.                                      PrinterPortPtr was zero
  376.  
  377. Performs the following:
  378. o  Calls DevIsItSafe (port driver call) to verify that the port is functioning 
  379.    and it is safe to proceed.
  380. o  Turns on the watch cursor to signal the user that it will take some time.
  381. o  Validates the print record passed by  calling PrValidate.
  382. o  Clears the internal error code (default, if nothing happens).
  383. o  Puts up a dialog indicating that printing is occurring (or preparing to 
  384.    print).
  385. o  If the user needs a GrafPort, create one and internally note that one was 
  386.    created (PrCloseDoc needs to know that one was created here).
  387. o  Initializes parameters (i.e., page number, document number, etc.).
  388. o  If deferred mode, create an initial page list (an array of handles to 
  389.    pictures) for 20 pages (arbitrary number to start).
  390. o  Do other initialization that might be needed to start a print job.
  391.  
  392. Possible errors:
  393.                          $1302        Indicates Port Not On
  394.  
  395.  
  396. PrCloseDoc               ($0F13)
  397.  
  398. Description:
  399.     Closes the GrafPort being used for printing.  For immediate mode, this 
  400.     routine ends the printing job.  For deferred mode, this routine ends the 
  401.     process allowing the job to be printed.
  402.  
  403. Passed:
  404.     PrintGrafPortPtr     LONG        Pointer to the GrafPort used for printing
  405.  
  406. Returned:
  407.     None
  408.  
  409. Performs the following:
  410. o  Checks that the last print driver call did not cause a Port Not On error.  
  411.    If the error occurred, do nothing and return.
  412. o  Call ClosePort (port driver call) to close the port.
  413. o  If the driver allocated a GrafPort in PrOpenDoc, dispose of it.
  414. o  If in immediate mode, do what is needed to shut things down.
  415. o  Takes down the information dialog box from PrOpenDoc.
  416.  
  417.  
  418. PrOpenPage               ($1013)
  419.  
  420. Description:
  421.     Begins a new page only if the page falls within the page range specified in 
  422.     the job subrecord.
  423.  
  424. Passed:
  425.     PrintGrafPortPtr     LONG        Pointer to the GrafPort used for printing
  426.     PageFramePtr         LONG        Pointer to the scaling parameter,
  427.                                      zero for none.
  428. Returned:
  429.     None
  430.  
  431. Performs the following:
  432. o  Looks at the driver's internal error value, and if an error has occurred, 
  433.    it returns without doing anything.
  434. o  Increments the page number.
  435. o  Calls SetPort to make the specified port the current port.
  436. o  Initializes the port and zeroes the boundary rectangle so no actual drawing 
  437.    occurs.
  438. o  If immediate mode, then do the following:
  439.      If this page is to be printed, install immediate mode procedures by 
  440.      doing the following:
  441. o  Create a procedure table (get the standard procedures. from SetStdProcs).
  442. o  Put pointers to your procedures into the table and call the QuickDraw II 
  443.    routine SetGrafProcs.  This causes QuickDraw II calls to print instead 
  444.    of writing to the GrafPort.
  445. o  If deferred mode, then do the following:
  446. o  If the current page is out of the page range, then return without 
  447.    doing anything further.
  448. o  If the user passes his own PageFramePtr , then get it.
  449. o  Open a picture by calling OpenPicture and adding its handle to the 
  450.    page list array described in PrOpenDoc.
  451. o  Set the ClipRgn and VisRgn to the sizing framing rectangle specified 
  452.    by PageFramePtr , or if none was specified, to the default of rPage.
  453.  
  454.  
  455. PrClosePage              ($1113)
  456.  
  457. Description:
  458.     This signals the end of a page.
  459.  
  460. Passed:
  461.     PrintGrafPortPtr     LONG        Pointer to the GrafPort used for printing
  462.  
  463. Returned:
  464.     None
  465.  
  466. Performs the following:
  467. o  Looks at the driver's internal error value and if a Port Not On error has 
  468.    occurred, it returns without doing anything.
  469. o  If immediate mode, do the following:
  470. o  If the current page is within the range of pages to be printed, then 
  471.    cause a form feed (unless no gap was specified).
  472. o  If deferred mode, do the following:
  473. o  If there was no picture generated, then do nothing and just return.
  474. o  Call SetPort to make the specified port the current port.
  475. o  Do a ClosePicture to close the picture.
  476.  
  477.  
  478. PrPicFile                ($1213)
  479.  
  480. Description:
  481.     Prints a picture file generated in deferred mode.
  482.  
  483. Passed:
  484.     PrintRecordHandle    LONG        Handle to the print record
  485.     PrintGrafPortPtr     LONG        Pointer to the GrafPort used for printing
  486.     StatusRecPtr         LONG        Pointer to the printer status record
  487.  
  488. Returned:
  489.     None
  490.  
  491. Performs the following:
  492. o  Looks at the driver's internal error value and if a Port Not On error has 
  493.    occurred, it returns without doing anything.
  494. o  If immediate mode, return without doing anything.
  495. o  If deferred mode, then do the following:
  496. o  If the error code is not zero (errors) then dispose of everything.
  497. o  Put up an information dialog indicating that printing is occurring.
  498. o  If PrintGrafPortPtr is NIL, create one and make a note of it.
  499. o  Call OpenPort to make the GrafPort the current port.
  500. o  If StatusRecPtr is NIL, use an internal one.
  501. o  Initialize the status record and the number of copies counter.
  502. o  If the idle proc in the print record is NIL, point to an internal one.
  503. o  Do The Following For Each Copy:
  504.    o  Calculate the number of bands to print one page and initialize the 
  505.       page counter.
  506.    o  Do The Following For Each Page:
  507.    o  Call the idle procedure routine and initialize the band counter.
  508.    o  Get the handle to the picture associated with the current page.
  509.    o  Set the dirty flag in the status record to FALSE.
  510.    o  If manual paper feed, put up a dialog and wait for a response.
  511.    o  Do The Following For Each Band:
  512.    o  Call the idle procedure.
  513.    o  Calculate the band rectangle and update icurband with the 
  514.       current band number.
  515.    o  Call the idle proc again.
  516.    o  Set the imaging flag in the status record to TRUE.
  517.    o  Call InitPort to reinitialize the port.
  518.    o  Adjust fields in the port to cause drawing into the band buffer.
  519.    o  Adjust fields in the location information field of the status 
  520.       record and calculate the sizing rectangle.
  521.    o  Calculate the boundary rectangle for the band and set the port 
  522.       rectangle to it.
  523.    o  Set the ClipRgn and the VisRgn to the sizing rectangle.
  524.    o  Initialize the band by filling it with white space.
  525.    o  Call DrawPicture to draw the picture into the band's rectangle.
  526.    o  Do whatever is needed to print the pixel image in the band's rectangle.
  527.    o  Clear the imaging flag.
  528.    o  Calculate the next band's position.
  529.    o  Increment the band's counter and loop back if not done.
  530.    o  If GAP was specified, cause a form feed.
  531.    o  Increment the page count to the next page and loop back if not done.
  532.    o  Increment the number of copies counter and loop back if not done.
  533. o  Free any buffers that you own and close the port.
  534. o  Dispose of the information dialog that you put up.
  535. o  Dispose of each picture in the picture list by calling KillPicture.
  536. o  Dispose of the picture list itself.
  537. o  Reset the cursor.
  538.  
  539.  
  540. PrError                  ($1413)
  541.  
  542. Description:
  543.     Gets the error code from the last Print Manager call.
  544.  
  545. Passed:
  546.     None
  547.  
  548. Returned:
  549.     LastError            WORD        Result code from last Print Manager call
  550.  
  551. Performs the following:
  552. o  Gets the driver's internal error value (which was determined by the last 
  553.    driver call) and sets the return parameter LastError to it.
  554.  
  555. Possible Errors:
  556.     noError              $0000
  557.     PrAbort              $0080       Indicates print job was aborted
  558.                          $1301       Indicates missing drivers
  559.                          $1302       Indicates Port Not On
  560.                          $1303       Indicates No Print Record
  561.                          $1306       Indicates PAP Connection Not Made
  562.                          $1307       Indicates Read/Write PAP Error
  563.                          $1308       Indicates Printer Connection Failed
  564.  
  565.  
  566. PrSetError               ($1513)
  567.  
  568. Description:
  569.     Sets the error value.
  570.  
  571. Passed:
  572.     ErrorNumber          WORD        Error number to be set
  573.  
  574. Returned:
  575.     None
  576.  
  577. Performs the following:
  578. o  Sets the driver's internal error value to the value of the passed 
  579.    ErrorNumber parameter.
  580.  
  581.  
  582. GetDeviceName            ($1713)
  583.  
  584. Description:
  585.     Used as a communications tool between the printer driver and port driver.
  586.  
  587. Passed:
  588.     None
  589.  
  590. Returned:
  591.     None
  592.  
  593. Performs the following:
  594. o  Calls the port driver routine PrDevPrChanged with the printer name as 
  595.    input.  This is necessary for drivers that work over AppleTalk.  The name 
  596.    passed as the parameter to PrDevPrChanged should be what AppleTalk uses in 
  597.    an NBPLookup situation; for AppleTalk, such a name should follow NBP 
  598.    conventions.
  599.  
  600.  
  601. PrDriverVer              ($2313)
  602.  
  603. Description:
  604.     Returns the version number of the currently installed printer driver.
  605.  
  606. Passed:
  607.     Wordspace            WORD       Space for results
  608.  
  609. Returned:
  610.     versionInfo          WORD       Printer driver's version number
  611.  
  612. Performs the following:
  613. o  Gets the internal version number of the printer driver and returns it on 
  614.    the stack at versionInfo.
  615.  
  616. Note:  The internal version number is stored major byte, minor byte 
  617.        (i.e., $0103 represents version 1.3)
  618.  
  619.  
  620. PrGetPrinterSpecs        ($1813)
  621.  
  622. Description:
  623.     Returns the type of printer and the printer's characteristics.
  624.  
  625. Passed:
  626.     Wordspace            WORD       Space for results
  627.     Wordspace            WORD       Space for results
  628.  
  629. Returned:
  630.     PrinterType          WORD       0 = undefined
  631.                                     1 = ImageWriter or ImageWriter II
  632.                                     2 = ImageWriter LQ
  633.                                     3 = LaserWriter family (except IIsc)
  634.                                     4 = Epson
  635.                                     $8001 = generic dot matrix printer
  636.                                     $8003 = generic laser printer
  637.     PrCharacteristics    WORD       Bits 15 - 2 = reserved, must be zero
  638.                                     Bits 1-0:  00 = cannot determine
  639.                                                01 = black and white only
  640.                                                10 = color capable
  641.  
  642. Performs the following:
  643. o  Returns characteristics intrinsic for the printer being supported.
  644.  
  645.  
  646. PrGetPgOrientation       ($3813)
  647.  
  648. Description:
  649.     Returns the page orientation from a print record.
  650.  
  651. Passed:
  652.     Wordspace            WORD       Space for result
  653.     PrintRecordHandle    LONG       Handle to the print record
  654.  
  655. Returned:
  656.     PgOrientation        WORD       Current page orientation:
  657.                                       0 = portrait
  658.                                       1 = landscape
  659.  
  660. Performs the following:
  661. o  Returns the page orientation from the current page setup information in the 
  662.    print record.
  663.  
  664.  
  665. Immediate Mode Procedures
  666.  
  667. To print in the immediate mode, you need to install procedures which cause 
  668. printing when you make QuickDraw II calls (as noted in PrOpenPage).  This 
  669. section describes the structure and parameters for these routines.
  670.  
  671. To install the immediate mode procedures, first create a procedure table for 
  672. sixteen entries (16*4 bytes) and fill it with the standard procedures by 
  673. calling SetStdProcs.  Once you have the standard procedures, install the 
  674. addresses of your procedures into it and call SetGrafProcs.  Installing your 
  675. procedure addresses causes the appropriate QuickDraw II calls to call your 
  676. procedures, which, in turn, perform the actual printing.
  677.  
  678. The routines that need to be written are known as QuickDraw II "bottleneck 
  679. procedures."  Access to the routines are from bank $E0 (accessed by doing a 
  680. JSL to the appropriate address in bank $E0).  When you call any of the 
  681. bottleneck procedures, the first direct page of QuickDraw II is active and the 
  682. following direct page locations are valid:
  683.  
  684.     PortRef              $24
  685.     MaxWidth             $20
  686.     MasterSCB            $08
  687.     UserId               $0A
  688.  
  689. Two bottleneck procedures, StdText and StdPixels, are of most concern when 
  690. writing immediate mode procedures.  (Refer to Apple IIGS Technical Note #34, 
  691. Low-Level QuickDraw II Routines for more information on bottleneck 
  692. procedures.)
  693.  
  694. The routine StdText (standard text) is the standard text drawing routine.  To 
  695. install this routine into your procedure table (as described above), make it 
  696. the first entry (offset of $00).  Once it's installed, you can access it by 
  697. doing a long call to absolute address $E01E04.  Its direct page parameters are 
  698. as follows:
  699.  
  700.     DrawVerb             $38        Describes the kind of text to draw.  There 
  701.                                     are three possible values:
  702.                                         DrawCharVerb    0
  703.                                         DrawTextVerb    1
  704.                                         DrawCStrVerb    2
  705.     TextPtr              $DA        If the draw verb is DrawTextVerb or 
  706.                                     DrawCStrVerb, TextPtr points to the text 
  707.                                     buffer or C string to draw.
  708.     TextLength           $D8        If the draw verb is DrawTextVerb, 
  709.                                     TextLength contains the number of bytes in 
  710.                                     the text buffer.
  711.     CharToDraw           $D6        If the draw verb is DrawCharVerb, 
  712.                                     CharToDraw contains the character to draw.
  713.  
  714. The routine StdPixels is the standard pixelmap drawing routine.  To install 
  715. this routine into your procedure table (as described above), put it at offset 
  716. $20.  Once it's installed, you can access it by doing a long call to absolute 
  717. address $E01E24.  Its direct page parameters are as follows:
  718.  
  719.     SrcLocInfo           $CC        The LocInfo record for the source pixel map
  720.     DestLocInfo          $0C        The LocInfo record for the destination 
  721.                                     pixel map
  722.     SrcRect              $DC        The source rectangle for the operation in 
  723.                                     local coordinates for the source pixel map 
  724.                                     (as described in the source LocInfo 
  725.                                     record)
  726.     DestRect             $1C        The destination rectangle for the 
  727.                                     operation in local coordinates for the 
  728.                                     destination pixel map (as described in the 
  729.                                     destination  LocInfo record)
  730.     XferMode             $E4        The mode to use for data transfer
  731.     RgnHandleA           $50        The handle to the first region to which 
  732.                                     drawing is clipped (usually the ClipRgn 
  733.                                     from the GrafPort)  A NIL handle is not 
  734.                                     allowed.  To signify no clipping, pass a 
  735.                                     handle to the WideOpen region, which is 
  736.                                     defined as 10 bytes:
  737.  
  738.                                         Length     $A        (word)
  739.                                         -MaxInt    -$3FFF    (word)
  740.                                         -MaxInt    -$3FFF    (word)
  741.                                         +MaxInt    +$3FFF    (word)
  742.                                         +MaxInt    +$3FFF    (word)
  743.  
  744.     RgnHandleB           $60        The handle to the second region to which 
  745.                                     drawing is clipped (usually the VisRgn 
  746.                                     from the GrafPort)  A NIL handle is not 
  747.                                     allowed.  To signify no clipping, pass a 
  748.                                     handle to the WideOpen region.
  749.     RgnHandleC           $70        The handle to the second region to which 
  750.                                     drawing is clipped (usually the mask 
  751.                                     region from the CopyPixels or the 
  752.                                     PaintPixels call)  A NIL handle is not 
  753.                                     allowed.  To signify no clipping, pass a 
  754.                                     handle to the WideOpen region.
  755.  
  756. Example:
  757.  
  758. ;*****************************************************************
  759. ;** Example of Immediate Mode Printer Procedures.               **
  760. ;*****************************************************************
  761.  
  762. Immedprocs    Start
  763.  
  764. SrcRect       equ $DC
  765. SrcLocInfo    equ $CC
  766. DrawVerb      equ $38
  767. TextPtr       equ $da
  768. TextLength    equ $d8
  769. CharToDraw    equ $d6
  770.  
  771. ;------------------------------------------------------------------
  772. ;
  773. ; _StdPixels Procedure (Prints Pixelmaps)
  774. ;
  775. ;------------------------------------------------------------------
  776. Pixel         Entry
  777.  
  778.               phb                  ;save data bank reg on stack
  779.               phk                  ;get program bank reg.
  780.               plb                  ;use as data bank reg.
  781.  
  782.               lda iPrErr           ;get errors
  783.               beq Continue         ;branch if none
  784.               brl ExitPixel        ;branch if errors
  785.  
  786. Continue      anop
  787. ;This gets the source rectangle and stores it at PixelRect
  788.               ldx #6
  789. MoveSrc       lda SrcRect,x
  790.               sta PixelRect,x
  791.               dex
  792.               dex
  793.               bpl MoveSrc
  794.  
  795. ;This gets the source LocInfo and stores it at PixelLoc 
  796.               ldx #16-2
  797. MoveLI        lda SrcLocInfo,x
  798.               sta PixelLoc,x
  799.               dex
  800.               dex
  801.               bpl MoveLI
  802.  
  803.               pushptr PixelLoc     ;push pointer to LocInfo
  804.               pushptr PixelRect    ;push pointer to rectangle
  805.  
  806. ;++++++++++++++++++++++
  807. ; Insert code here to print a pixelmap
  808. ;    INPUT:    PixelLoc     LONG, Pointer to pixel LocInfo
  809. ;              PixelRect    LONG, Pointer to pixels BoundsRect
  810. ;           SP->
  811. ;++++++++++++++++++++++
  812.  
  813. Exitpixel     lda #0               ;return with no errors
  814.               clc
  815.               plb                  ;restore data bank
  816.               rtl                  ;returnith long
  817.     
  818. PixelLoc      ds 16                ;pixel LocInfo
  819. PixelRect     ds 8                 ;pixel rectangle
  820.  
  821.  
  822. ;------------------------------------------------------------------
  823. ;
  824. ; _StdText Procedure (Prints Standard Text)
  825. ;
  826. ;------------------------------------------------------------------
  827. StdText       Entry
  828.  
  829.               phb                  ;save data bank reg on stack
  830.               phk                  ;get program bank reg. 
  831.               plb                  ;use as data bank reg.
  832.  
  833.               pushptr PenPos
  834.               _GetPen              ;current pen pos. -> PenPos
  835.  
  836. ;++++++++++++++++++++++
  837. ; Insert Code Here to move the printers head to the corresponding
  838. ; PenPos position (if needed).
  839. ;++++++++++++++++++++++
  840.  
  841.               pushword #0          ;space for textwidth
  842.                                    ;(for call to _TextWidth)
  843.  
  844.               lda DrawVerb         ;get DrawVerb
  845.               beq DoCar            ;if DrawVerb=0 then DoCar
  846.  
  847.               cmp #1
  848.               beq Dotext2          ;if DrawVerb=1 then Dotext2
  849. ;
  850. ;We get here if it's a "C" string (DrawVerb=2)
  851. ;
  852. DoCstring     anop
  853.               sep #$20
  854.               longa off
  855. ;Search down through string looking for terminator to calc. length
  856.               ldy #0
  857. KeepLooking   lda [TextPtr],y
  858.               beq TheEnd
  859.               iny
  860.               bra KeepLooking
  861. TheEnd        rep #$20
  862.               longa on
  863.               lda TextPtr+2
  864.               pha                  ;push the pointer to string
  865.               lda Textptr
  866.               pha
  867.               phy                  ;push the length of sting
  868.               bra Common
  869. ;
  870. ;We get here if it's just one character (DrawVerb=0)
  871. ;
  872. DoCar         anop
  873.               pushword #0
  874.               tdc
  875.               clc
  876.               adc #CharToDraw      ;calculate addr. of char.
  877.               pha                  ;push addr. of character
  878.               pushword #1          ;push length of one char.
  879.               bra Common
  880. ;
  881. ;We get here if it's a string of text (DrawVerb=1)
  882. ;
  883. DoText2       anop
  884.               lda TextPtr+2
  885.               pha                  ;push pointer to the string
  886.               lda Textptr
  887.               pha
  888.               lda TextLength
  889.               pha                  ;push the strings length
  890. Common        lda 5,s              ;Dup the last 3 words of
  891.               pha                  ;the stack (for _TextWidth)
  892.               lda 5,s
  893.               pha
  894.               lda 5,s
  895.               pha
  896. ;++++++++++++++++++++++
  897. ; Insert code here to print the text
  898. ;
  899. ;    INPUT:    TextPointer    LONG, Pointer to text to print
  900. ;              TextLength     WORD, No. of bytes to print
  901. ;          SP->
  902. ;++++++++++++++++++++++
  903.               _TextWidth           ;get the texts width (DH)
  904.               pushword #0          ;set (DV)=0
  905.               _Move                ;move current pen location
  906.  
  907. ExitText      lda #0               ;return with no errors
  908.               clc
  909.               plb                  ;restore data bank
  910.               rtl                  ;returnith long
  911.  
  912. PenPos        ds 4                 ;pen position
  913.               end
  914.  
  915.  
  916. Further Reference
  917. _____________________________________________________________________________
  918.   o  Apple IIGS Toolbox Reference, Volumes 1 & 2
  919.  
  920.